<template>
  <div class="van-coupon grideWrap">
    <van-grid :column-num="4" :border="false">
      <van-grid-item
        v-for="item in list"
        :key="item.title"
        @click="toModule(item.name)"
      >
        <div
          class="van-grid-item__content van-grid-item__content--center"
          style="padding: 0"
        >
          <i class="van-badge__wrapper van-icon van-grid-item__icon">
            <img
              style="width: 50px; height: 50px"
              class="van-icon__image"
              :src="item.icon"
            />
          </i>
          <span class="van-grid-item__text">{{ item.title }}</span>
        </div>
      </van-grid-item>
    </van-grid>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from 'vue-router'

const router = useRouter()

interface Props {
  list: Array<{ title: string; icon: string; name: string }>
}

const props = defineProps<Props>()

const toModule = (item: string) => {
  router.push({ name: item })
}
</script>
